home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / items.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  2KB  |  88 lines

  1. #include <iostream.h>
  2. #include "flyaway.h"
  3. #include "items.h"
  4.  
  5.  
  6. items::items(void)
  7. {
  8.    keys_on_hand = FALSE;
  9.    candy_on_hand = FALSE;
  10.    ticket_on_hand = FALSE;
  11.    money_on_hand = FALSE;
  12. }
  13.  
  14.  
  15. void items::add_item(word item_to_add)
  16. {
  17.    switch (item_to_add) {
  18.       case keys   : keys_on_hand = TRUE;
  19.                     break;
  20.       case candy  : candy_on_hand = TRUE;
  21.                     break;
  22.       case ticket : ticket_on_hand = TRUE;
  23.                     break;
  24.       case money  : money_on_hand = TRUE;
  25.                     break;
  26.       default     : break;
  27.    }
  28. }
  29.  
  30.  
  31. void items::drop_item(word item_to_drop)
  32. {
  33.    switch (item_to_drop) {
  34.       case keys   : keys_on_hand = FALSE;
  35.                     break;
  36.       case candy  : candy_on_hand = FALSE;
  37.                     break;
  38.       case ticket : ticket_on_hand = FALSE;
  39.                     break;
  40.       case money  : money_on_hand = FALSE;
  41.                     break;
  42.       default     : break;
  43.    }
  44. }
  45.  
  46.  
  47. int items::item_here(word item_to_check)
  48. {
  49.    switch (item_to_check) {
  50.       case keys   : return keys_on_hand;
  51.                     break;
  52.       case candy  : return candy_on_hand;
  53.                     break;
  54.       case ticket : return ticket_on_hand;
  55.                     break;
  56.       case money  : return money_on_hand;
  57.                     break;
  58.       default     : return FALSE;
  59.                     break;
  60.    }
  61. }
  62.  
  63.  
  64. void items::list_items(void)
  65. {
  66.    if (keys_on_hand)
  67.       cout << "You have the keys to your car.\n";
  68.    if (candy_on_hand)
  69.       cout << "You have two candy bars.\n";
  70.    if (ticket_on_hand)
  71.       cout << "You have a ticket for your dream vacation.\n";
  72.    if (money_on_hand)
  73.       cout << "You have a couple of dollars of loose change.\n";
  74. }
  75.  
  76.  
  77. void items::list_items_in_room(void)
  78. {
  79.    if (keys_on_hand)
  80.       cout << "There are car keys here.\n";
  81.    if (candy_on_hand)
  82.       cout << "There are some candy bars here.\n";
  83.    if (ticket_on_hand)
  84.       cout << "There is an airplane ticket here.\n";
  85.    if (money_on_hand)
  86.       cout << "There is some money here.\n";
  87. }
  88.